#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
const int N = 10010;
int a[N],cnt;
int main()
{
	int l, m;
	cin >> l >> m;
	while (m--)
	{
		int u, v;
		cin >> u >> v;
		for (int i = u; i <= v; i++)
		{
			a[i] = 1;
		}
	}
	for (int i = 0; i <= l; i++)
	{
		if (a[i] == 0)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}